<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>get_lowest_layer</title>
<link rel="stylesheet" href="../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="Chapter 1. Boost.Beast">
<link rel="up" href="../ref.html" title="This Page Intentionally Left Blank 2/2">
<link rel="prev" href="boost__beast__iequals.html" title="iequals">
<link rel="next" href="boost__beast__beast_close_socket.html" title="beast_close_socket">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__beast__iequals.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__beast__beast_close_socket.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="beast.ref.boost__beast__get_lowest_layer"></a><a class="link" href="boost__beast__get_lowest_layer.html" title="get_lowest_layer">get_lowest_layer</a>
</h4></div></div></div>
<p>
        <a class="indexterm" name="idm44861252572960"></a>
      </p>
<p>
        Return the lowest layer in a stack of stream layers.
      </p>
<h5>
<a name="beast.ref.boost__beast__get_lowest_layer.h0"></a>
        <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.synopsis"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.synopsis">Synopsis</a>
      </h5>
<p>
        Defined in header <code class="literal">&lt;<a href="../../../../../../boost/beast/core/stream_traits.hpp" target="_top">boost/beast/core/stream_traits.hpp</a>&gt;</code>
      </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span>
    <span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="identifier">lowest_layer_type</span><span class="special">&lt;</span> <span class="identifier">T</span> <span class="special">&gt;&amp;</span>
<span class="identifier">get_lowest_layer</span><span class="special">(</span>
    <span class="identifier">T</span><span class="special">&amp;</span> <span class="identifier">t</span><span class="special">);</span>
</pre>
<h5>
<a name="beast.ref.boost__beast__get_lowest_layer.h1"></a>
        <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.description"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.description">Description</a>
      </h5>
<p>
        If <code class="computeroutput"><span class="identifier">t</span><span class="special">.</span><span class="identifier">next_layer</span><span class="special">()</span></code>
        is well-defined, returns <code class="computeroutput"><span class="identifier">get_lowest_layer</span><span class="special">(</span><span class="identifier">t</span><span class="special">.</span><span class="identifier">next_layer</span><span class="special">())</span></code>.
        Otherwise, it returns <code class="computeroutput"><span class="identifier">t</span></code>.
        A stream layer is an object of class type which wraps another object through
        composition, and meets some or all of the named requirements of the wrapped
        type while optionally changing behavior. Examples of stream layers include
        <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">ssl</span><span class="special">::</span><span class="identifier">stream</span></code>
        or <a class="link" href="boost__beast__websocket__stream.html" title="websocket::stream"><code class="computeroutput"><span class="identifier">beast</span><span class="special">::</span><span class="identifier">websocket</span><span class="special">::</span><span class="identifier">stream</span></code></a>. The owner of a stream layer
        can interact directly with the wrapper, by passing it to stream algorithms.
        Or, the owner can obtain a reference to the wrapped object by calling <code class="computeroutput"><span class="identifier">next_layer</span><span class="special">()</span></code>
        and accessing its members. This is necessary when it is desired to access
        functionality in the next layer which is not available in the wrapper. For
        example, <a class="link" href="boost__beast__websocket__stream.html" title="websocket::stream"><code class="computeroutput"><span class="identifier">websocket</span><span class="special">::</span><span class="identifier">stream</span></code></a> permits reading and writing,
        but in order to establish the underlying connection, members of the wrapped
        stream (such as <code class="computeroutput"><span class="identifier">connect</span></code>)
        must be invoked directly. Usually the last object in the chain of composition
        is the concrete socket object (for example, a <code class="computeroutput"><span class="identifier">net</span><span class="special">::</span><span class="identifier">basic_socket</span></code>
        or a class derived from it). The function <a class="link" href="boost__beast__get_lowest_layer.html" title="get_lowest_layer"><code class="computeroutput"><span class="identifier">get_lowest_layer</span></code></a> exists to easily
        obtain the concrete socket when it is desired to perform an action that is
        not prescribed by a named requirement, such as changing a socket option,
        cancelling all pending asynchronous I/O, or closing the socket (perhaps by
        using <a class="link" href="boost__beast__close_socket.html" title="close_socket"><code class="computeroutput"><span class="identifier">close_socket</span></code></a>).
      </p>
<h5>
<a name="beast.ref.boost__beast__get_lowest_layer.h2"></a>
        <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.example"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.example">Example</a>
      </h5>
<pre class="programlisting"><span class="comment">// Set non-blocking mode on a stack of stream</span>
<span class="comment">// layers with a regular socket at the lowest layer.</span>
<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">Stream</span><span class="special">&gt;</span>
<span class="keyword">void</span> <span class="identifier">set_non_blocking</span> <span class="special">(</span><span class="identifier">Stream</span><span class="special">&amp;</span> <span class="identifier">stream</span><span class="special">)</span>
<span class="special">{</span>
    <span class="identifier">error_code</span> <span class="identifier">ec</span><span class="special">;</span>
    <span class="comment">// A compile error here means your lowest layer is not the right type!</span>
    <span class="identifier">get_lowest_layer</span><span class="special">(</span><span class="identifier">stream</span><span class="special">).</span><span class="identifier">non_blocking</span><span class="special">(</span><span class="keyword">true</span><span class="special">,</span> <span class="identifier">ec</span><span class="special">);</span>
    <span class="keyword">if</span><span class="special">(</span><span class="identifier">ec</span><span class="special">)</span>
        <span class="keyword">throw</span> <span class="identifier">system_error</span><span class="special">{</span><span class="identifier">ec</span><span class="special">};</span>
<span class="special">}</span>
</pre>
<h5>
<a name="beast.ref.boost__beast__get_lowest_layer.h3"></a>
        <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.parameters"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.parameters">Parameters</a>
      </h5>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                <p>
                  Name
                </p>
              </th>
<th>
                <p>
                  Description
                </p>
              </th>
</tr></thead>
<tbody><tr>
<td>
                <p>
                  <code class="computeroutput"><span class="identifier">t</span></code>
                </p>
              </td>
<td>
                <p>
                  The layer in a stack of layered objects for which the lowest layer
                  is returned.
                </p>
              </td>
</tr></tbody>
</table></div>
<h5>
<a name="beast.ref.boost__beast__get_lowest_layer.h4"></a>
        <span class="phrase"><a name="beast.ref.boost__beast__get_lowest_layer.see_also"></a></span><a class="link" href="boost__beast__get_lowest_layer.html#beast.ref.boost__beast__get_lowest_layer.see_also">See
        Also</a>
      </h5>
<p>
        <a class="link" href="boost__beast__close_socket.html" title="close_socket"><code class="computeroutput"><span class="identifier">close_socket</span></code></a>,
        <a class="link" href="boost__beast__lowest_layer_type.html" title="lowest_layer_type"><code class="computeroutput"><span class="identifier">lowest_layer_type</span></code></a>
      </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2016-2019 Vinnie
      Falco<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="boost__beast__iequals.html"><img src="../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../ref.html"><img src="../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="boost__beast__beast_close_socket.html"><img src="../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
